cmake_minimum_required(VERSION 3.6.0)
if (NOT ROOT_DIR)
    # set(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../")
    get_filename_component(ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../" ABSOLUTE)
endif()
set(CURRENT_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/toolchain_common.cmake)
include(${CURRENT_CMAKE_PATH})

# set the other flags
# set(CMAKE_C_STANDARD_LIBRARIES_INIT "-lm -ldl")
# set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "-lm -ldl")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lm -ldl")
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

add_definitions(-DUSE_HTNICE)
add_definitions(-D__GNU__)

if (NOT COMPILER_ROOT)
    set(COMPILER_ROOT ${ROOT_DIR}/buildtools/toolchains/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf)
endif()

set(CMAKE_SYSROOT  "${COMPILER_ROOT}/arm-linux-gnueabihf/libc")
set(CMAKE_C_COMPILER   "${COMPILER_ROOT}/bin/arm-linux-gnueabihf-gcc")
set(CMAKE_CXX_COMPILER "${COMPILER_ROOT}/bin/arm-linux-gnueabihf-g++")
set(CMAKE_AR           "${COMPILER_ROOT}/bin/arm-linux-gnueabihf-ar")
set(CMAKE_RANLIB       "${COMPILER_ROOT}/bin/arm-linux-gnueabihf-ranlib")
set(CMAKE_STRIP        "${COMPILER_ROOT}/bin/arm-linux-gnueabihf-strip")
set(CMAKE_SYSTEM_PROCESSOR "armv7-a")
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING "TRUE")
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})

message(INFO " C compiler is ${CMAKE_C_COMPILER}")
message(INFO " CXX compiler is ${CMAKE_CXX_COMPILER}")

# add_definitions(-DPRODUCT_${PRODUCT_NAME})
# add_definitions(-DPRODUCT_NAME=${PRODUCT_NAME})
# add_definitions(-DSTDC_HEADERS
#   -DHAVE_LIMITS_H
#   -DHAVE_DECL_ISNAN
#   -DHAVE_DECL_ISINF
#   -DHAVE_DECL_INFINITY
#   -DHAVE_DECL_NAN
#   -DHAVE_SNPRINTF
#   -DHAVE_STDARG_H
#   -DHAVE_VASPRINTF
#   -DHAVE_STRDUP)